<?php
namespace App\Module\Admin\Controller;

use App\Common\Controller\AbstractController;
use App\Module\Admin\Request\Teacher\CreateRequest;
use App\Module\Admin\Request\Teacher\UpdateRequest;
use App\Module\Admin\Service\TeacherService;
use Hyperf\Di\Annotation\Inject;

class TeacherController extends AbstractController{

    /**
     * @Inject()
     * @var TeacherService $teacherService
     */
    private $teacherService;

    public function search(){
        $name = $this->request->input("name");
        $mobile = $this->request->input("mobile");
        $pagesize = $this->request->input("pagesize");

        return $this->response->json($this->teacherService->search($name,$mobile,$pagesize));
    }

    public function add(CreateRequest $request){
        return $this->response->json($this->teacherService->create($request));
    }

    public function getById(int $id){
        return $this->response->json($this->teacherService->getById($id));
    }

    public function edit(UpdateRequest $request,int $id){
        return $this->response->json($this->teacherService->update($request,$id));
    }

    public function delete(int $id){
        return $this->response->json($this->teacherService->delete($id));
    }

    public function show(int $id){
        return $this->response->json($this->teacherService->show($id));
    }
}
